//package org.dxy.domain.handler.equipment;
//
//import com.google.common.eventbus.EventBus;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.dxy.domain.adapter.port.CommandHandler;
//import org.dxy.domain.adapter.repository.IEquipmentRepository;
//import org.dxy.domain.command.equipment.FailProcessCommand;
//import org.dxy.domain.model.aggregate.Equipment;
//import org.dxy.auth.common.CommandResult;
//import org.springframework.stereotype.Component;
//
///**
// * @description: 工艺步骤执行失败命令处理器
// * @author: dxy
// * @createTime: 2025/6/26 10:30
// */
//@Slf4j
//@Component
//@RequiredArgsConstructor
//public class FailProcessCommandHandler implements CommandHandler<FailProcessCommand, Void> {
//
//    private final IEquipmentRepository equipmentRepository;
//    private final EventBus eventBus;
//
//    @Override
//    public CommandResult<Void> handle(FailProcessCommand command) {
//        Equipment equipment = equipmentRepository.findById(command.getEquipmentId());
//        if (equipment == null) {
//            log.error("未找到设备，command={}", command);
//            return CommandResult.fail("设备不存在");
//        }
//
//        equipment.failProcess(command);
//        equipmentRepository.save(equipment);
//        equipment.getDomainEvents().forEach(eventBus::post);
//        equipment.clearDomainEvents();
//
//        log.info("记录工艺步骤执行失败成功, command={}", command);
//        return CommandResult.ok("记录工艺步骤执行失败成功");
//    }
//}
